/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package martino;

/**
 *
 * @author sempere
 */

public class Strings {

	public static String defines = "#define NOTESONSIZE 32\n#define CHANNELNUM 4\n#define ENDLIST -2\n#define EMPTYPOS -1\n#define NONOTE -1\n";

	public static String noteVectorsPoly = "int __notesOn [CHANNELNUM][NOTESONSIZE];\n";

	public static String noteVectorsMono = "int __noteOn [CHANNELNUM];\n";

	public static String noteOff = "void noteOff(int channel, int pitch, int velocity){\n\t Serial.write(0x90+channel);\n\t Serial.write(pitch);\n\t Serial.write(0);\n}\n";

	public static String noteOn = "void noteOn(int channel, int pitch, int velocity) {\n\tSerial.write(0x90+channel);\n\tSerial.write(pitch);\n\tSerial.write(0x45);\n}\n";
    
        public static String soundOffMono = "void soundOffMono(int channel){\n\tif(__noteOn[channel] != NONOTE){\n\t\tnoteOff(channel, __noteOn[channel], 0x45);\n\t}\n\t__noteOn[channel] = NONOTE;\n}\n";

	public static String playNoteMono = "void playNoteMono(int channel, int pitch, int velocity){\n\tif(__noteOn[channel] != pitch){\n\t\tif(__noteOn[channel]!=NONOTE){\n\t\t\tnoteOff(channel,__noteOn[channel], velocity);\n\t\t}\n\t\t__noteOn[channel] = pitch;\n\t\tnoteOn(channel, pitch, velocity);\n\t}\n}\n";
	
	public static String playNotePoly = "void playNotePoly(int channel, int pitch, int velocity){\n\tint notePos = -1;\n\tfor(int i=0; i< NOTESONSIZE; i++){\n\t\tif(__notesOn[channel][i]==pitch){\n\t\t\treturn;\n\t\t} else if(__notesOn[channel][i] == EMPTYPOS && notePos == -1){\n\t\t\tnotePos = i;\n\t\t} else if(__notesOn[channel][i] == ENDLIST){\n\t\t\tif(notePos == -1){\n\t\t\t\tnotePos = i;\n\t\t\t\t__notesOn[channel][i+1] = ENDLIST;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(notePos >= 0){\n\t\t__notesOn[channel][notePos] = pitch;\n\t\tnoteOn(channel,pitch,velocity);\n\t}\n}\n";

	public static String silenceNotePoly = "void silenceNotePoly(int channel, int pitch, int velocity){\n\tint notePos = -1;\n\tfor(int i=0; i< NOTESONSIZE; i++){\n\t\tif(__notesOn[channel][i]==pitch){\n\t\t\tif(__notesOn[channel][i+1]==ENDLIST){\n\t\t\t\t__notesOn[channel][i] = ENDLIST;\n\t\t\t} else {\n\t\t\t\t__notesOn[channel][i] = EMPTYPOS;\n\t\t\t}\n\t\t\tnoteOff(channel,pitch,velocity);\n\t\t\tbreak;\n\t\t} else if(__notesOn[channel][i] == ENDLIST){\n\t\t\tbreak;\n\t\t}\n\t}\n}\n"; 
        
	public static String soundOffPoly = "void soundOffPoly(int channel){\n\tfor(int i = 0; i< NOTESONSIZE; i++){\n\t\tif(__notesOn[channel][i]== ENDLIST){\n\t\t\tbreak;\n\t\t} else if(__notesOn[channel][i]!= EMPTYPOS){\n\t\t\tnoteOff(channel,__notesOn[channel][i],0);\n\t\t}\n\t}\n\t__notesOn[channel][0] = ENDLIST;\n}\n";

	public static String setupMono = "\tfor(int i=0; i<CHANNELNUM; i++){\n\t\t__noteOn[i] = NONOTE;\n\t}\n\tSerial.begin(31250);\n";

	public static String setupPoly = "\tfor(int i=0; i<CHANNELNUM; i++){\n\t\t__notesOn[i][0] = ENDLIST;\n\t}\n\tSerial.begin(31250);\n";

	public static String pitchBend = "void pitchbend(int channel, int bendvalue){\n\tint pitchbendcode = 0xE0;\n\tint pitchhigh = bendvalue>>7;\n\tint pitchlow = bendvalue<<8;\n\tpitchlow = pitchlow>>8;\n\tSerial.write(pitchbendcode+channel);\n\tSerial.write(pitchhigh);\n\tSerial.write(pitchlow);\n}\n";



	
}
